import random
import numpy as np

def generate_random_array(size, min_val=0, max_val=10000):
    """生成随机整数数组"""
    return [random.randint(min_val, max_val) for _ in range(size)]

def generate_nearly_sorted_array(size, swap_times=10):
    """生成几乎有序的数组"""
    arr = list(range(size))
    for _ in range(swap_times):
        i, j = random.randint(0, size-1), random.randint(0, size-1)
        arr[i], arr[j] = arr[j], arr[i]
    return arr

def generate_reversed_array(size):
    """生成逆序数组"""
    return list(range(size, 0, -1))

def generate_few_unique_array(size, unique_num=10):
    """生成少量唯一值的数组"""
    base = [random.randint(0, 10000) for _ in range(unique_num)]
    return [random.choice(base) for _ in range(size)]

def generate_test_cases():
    """生成各种测试用例"""
    test_cases = {
        
        "small_random": generate_random_array(20),
        "medium_random": generate_random_array(1000),
        "large_random": generate_random_array(100000),
        "small_sorted": list(range(20)),
        "large_sorted": list(range(100000)),
        "small_reversed": list(range(20, 0, -1)),
        "large_reversed": list(range(100000, 0, -1)),
        "nearly_sorted": generate_nearly_sorted_array(1000),
        "few_unique": generate_few_unique_array(1000),
        "all_same": [5] * 1000,
        "empty": [],
        "single": [1]
    }
    return test_cases

if __name__ == "__main__":
    # 保存测试用例到文件
    import json
    test_cases = generate_test_cases()
    with open("test_cases.json", "w") as f:
        json.dump(test_cases, f)
